import 'react-app-polyfill/stable';
import "lib-flexible"
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from "react-redux";
import {store} from './store'
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import api from './axios'
import appConfig from './config'
import utils from './js/utils.js'
import validator from './js/validator.js'
import localforage from 'localforage'
// import { Provider as KeepAliveProvider, KeepAlive} from 'react-keep-alive';

appConfig.init()

//  本地存储初始化
window.localforage = localforage
window.localforage.config({
    driver: navigator.userAgent.includes('WindowsWechat') ? localforage.LOCALSTORAGE : [localforage.INDEXEDDB, localforage.WEBSQL, localforage.LOCALSTORAGE],
    name: appConfig.localforage_name
});

React.$api = api
React.$appConfig = appConfig
React.$utils = utils
React.$check = validator

const rootElement = document.getElementById("root");
ReactDOM.render(
    <Provider store={store}>
        {/*<KeepAliveProvider include={['setUserInfo', 'showUserInfo']}>*/}
            <App/>
        {/*</KeepAliveProvider>*/}
    </Provider>,
    rootElement
)

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
